﻿<cfsilent>
	<cfscript>
		
				
		temFile = GetTempDirectory() & createUUID() & ".xls";
		downFile = URLEncodedFormat("课程系数设置样表", "utf-8");
		
		excel = getProperty("serviceFactory").getBean("spreadSheetObject");
		
		/*公式列表*/
		
		sql = "SELECT c.fun_name 
				FROM t_workload_fun c 
				ORDER BY c.fun_id DESC";
			
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_function = queryObj.execute( sql=sql ).getResult();
		
		/* 创建工作簿 */
		spreadsheetObj = excel.SpreadSheetNew("课程系数设置", false);
		
		/* 添加表头 */
		excel.SpreadsheetAddrow(spreadsheetObj, "课程号,课程名称,双语系数,实践系数,主讲工作量权重量比,第二主讲工作量权重量比,助教工作量权重量比,编制分类,理论工作量计算公式,实践工作量计算公式");
		
		/* 添加参考信息 */
		excel.SpreadsheetCreateSheet (spreadsheetObj, "计算公式参考");
		excel.SpreadsheetSetActiveSheet (spreadsheetObj, "计算公式参考");
		excel.SpreadsheetAddrow(spreadsheetObj, "公式名称");
		for (a = 1; a lte rs_function.recordCount; a++) {
			excel.SpreadsheetAddrow(spreadsheetObj, rs_function["fun_name"][a]);
		}
		excel.SpreadsheetSetActiveSheet (spreadsheetObj, "课程系数设置");
		excel.SpreadSheetWrite(spreadsheetObj, temFile, true);
	</cfscript> 

	<cfheader name="Content-Disposition" value="attachment; filename=#downFile#.xls" />
	<cfcontent file="#temFile#" reset="yes" type="application/msexcel" deletefile="yes" />	

</cfsilent>